<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>发送ajax请求</title>

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.2.4/jquery.js"></script>
    <script src="./js/tools.js"></script>
</head>

<body>
    <button id="btnNode">获取后端的数据</button>
    <button id="btnNode02">获取后端的数据-jsonp</button>
    <script>
        btnNode.onclick = function () {
            // $.ajax({
            //     url:"http://localhost:8080/users",
            //     type:"get",
            //     success:function(data) {
            //         console.log(data);
            //     }
            // })

            $.ajax({
                url: obj.baseUrl+"/users",
                type: "post",
                success: function (result) {
                    //console.log(data);
                    if (result.status == 200) {
                        console.log(result.data);
                    } else {
                        console.log(result.msg);
                    }
                }
            })
        }

        btnNode02.onclick = function () {
            // $.ajax({
            //     url:"http://localhost:8080/users",
            //     type:"get",
            //     success:function(data) {
            //         console.log(data);
            //     }
            // })

            $.ajax({
                url: "http://localhost:8080/users02",
                type: "get",
                dataType: "jsonp",
                success: function (data) {
                    console.log(data);
                }
            })
        }
    </script>

</body>

</html>